<template>
  <div style="padding: 6px;">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
      <el-form-item label="start" prop="startDate">
        <el-date-picker style="width: 160px" v-model="queryParams.startDate" type="date" value-format="yyyy-MM-dd"></el-date-picker>
      </el-form-item>
      <el-form-item label="end" prop="endDate">
        <el-date-picker style="width: 160px" v-model="queryParams.endDate" type="date" value-format="yyyy-MM-dd"></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="loadData">search</el-button>
      </el-form-item>
    </el-form>

    <el-table :data="logObj.list" border style="width: 100%">
      <el-table-column label="User Name" prop="username"></el-table-column>
      <el-table-column label="LoginTime">
        <template v-slot="scope">
          <DateFormat :value="scope.row.logtime" :format="'YYYY-MM-DD HH:mm'"></DateFormat>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination v-if="logObj.total>queryParams.pageSize" class="center" background layout="total, prev, pager, next"
                   @current-change="loadData" :total="logObj.total"
                   :current-page.sync="queryParams.pageNum" :page-size="queryParams.pageSize">
    </el-pagination>
  </div>
</template>

<script>
import request from '@/utils/request'
import dayjs from "dayjs";
export default {
  data() {
    return {
      queryParams: {
        pageNum: 1,
        pageSize: 5,
        startDate: dayjs().add(-7, 'day').format('YYYY-MM-DD'),
        endDate: ''
      },
      logObj: {},
    }
  },
  mounted() {
    this.loadData()

  },
  methods: {
    loadData() {
      request({
        url: '/sys/loginlog/pagelog',
        data: this.queryParams
      }).then(res => {
        const { data } = res
        this.logObj = data
      })
    },
  }
}
</script>
